//
//  DateSelectView.m
//  dyseller
//
//  Created by 红喇叭 on 2017/8/23.
//  Copyright © 2017年 红喇叭. All rights reserved.
//

#import "DateSelectView.h"


@implementation DateSelectView

- (instancetype)initWithFrame:(CGRect)frame selectDate:(NSDate *)date{
    self = [super initWithFrame:frame];
    if(self){
        CGFloat width = self.bounds.size.width;
        CGPoint origin = CGPointMake(0, 22.0);
        
        _calendar = [[GFCalendarView alloc] initWithFrameOrigin:origin width:width selectDate:date];
        
        // 点击某一天的回调
       self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
        
        self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removeView)];
        
        self.userInteractionEnabled = YES;
        tap.delegate = self;
        [self addGestureRecognizer:tap];

        [self addSubview:_calendar];
    }
    return self;
}


- (void)removeView{
    [self removeFromSuperview];
}



-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
    
    if ([touch.view isDescendantOfView:self.calendar]) {
        return NO;
    }
    
    return YES;
    
}
@end
